// 获取所有列表项名称
var lb = document.querySelector('.lb')
var xhr = new XMLHttpRequest()
xhr.open('get','http://47.116.75.38:8101/front/company')
xhr.send(null)
xhr.onload = function () {
  var res = JSON.parse(xhr.response)
  res.data.forEach(function (itme) {
    var div = document.createElement('div')
    div.classList.add('lb-all')
    var i = document.createElement('i')
    i.className = 'iconfont icon-left-s i'
    var span = document.createElement('span')
    span.innerText = itme.title
    div.appendChild(i)
    div.appendChild(span)
    lb.appendChild(div)
    var ul = document.createElement('ul')
    ul.className = 'all-tow all-ul al'
    var li = document.createElement('li')
    li.classList.add('all-li')
    var p = document.createElement('p')
    p.innerText = itme.content
    li.appendChild(p)
    ul.appendChild(li)
    lb.appendChild(ul)
  })
  //获取所有lb-all
  var lbAll = document.querySelectorAll('.lb-all')
  var alls = document.querySelectorAll('.al')
  var icon = document.querySelectorAll('.i')
  for(let i = 0; i < lbAll.length; i++){
    lbAll[i].onclick = function () {
      alls[i].classList.toggle('allll')
      icon[i].classList.toggle('icon')
    }
  }
}





var fh = document.querySelector('.fh')
document.onscroll = function () {
  if (document.documentElement.scrollTop > 400){
    fh.style.display = 'block'
  }
  if (document.documentElement.scrollTop < 300){
    fh.style.display = 'none'
  }
}

fh.onclick = function () {
  document.documentElement.scrollTop = 0
  fh.style.display = 'none'
}
